/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistencia;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import modelo.Setor;

/**
 *
 * @author Caps
 */
@Stateless
public class SetorFacade extends AbstractFacade<Setor> {
    @PersistenceContext(unitName = "SagrauPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public SetorFacade() {
        super(Setor.class);
    }
    
        public List<Setor> select(String setor){

        TypedQuery<Setor> q = getEntityManager().createQuery(
                "select s from Setor s where s.strCodigo =:arg1", Setor.class);
                q.setParameter("arg1", setor);

        q.setMaxResults(1);

        List<Setor> lista = q.getResultList();
        if (lista == null) {
            return null;
        }

        return lista;
    }
    
}
